package com.authine.cloudpivot.ext.service.organiztion;

import com.authine.cloudpivot.ext.dto.system.OrganizationDto;
import com.authine.cloudpivot.ext.service.account.AccountService;
import com.authine.cloudpivot.ext.service.account.impl.AccountServiceImpl;
import com.authine.cloudpivot.ext.utils.system.OrgUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;

import java.util.*;

@Slf4j
public class OrganizationService {

    /**
     * 通过组织id获取结算组织ID
     * @param orgId 组织ID
     * @return
     */
    public OrganizationDto getTransactionOrganiztionId(String orgId){
        OrganizationDto orgByOrgId = OrgUtils.getOrgByOrgId(orgId);
        if(!CollectionUtils.isEmpty(orgByOrgId.getTransaction_organization_id())){
            return OrgUtils.getOrgByOrgId(orgByOrgId.getTransaction_organization_id().get(0).getId());
        }
        return null;
    }

    /**
     * 通过组织ID获取组织信息
     * @param orgId 组织ID
     * @return 组织对象
     */
    public OrganizationDto getOrganizationById(String orgId){
        return OrgUtils.getOrgByOrgId(orgId);
    }

    /**
     * 通过组织ID获取组织信息
     * @param orgIds 组织ID
     *               TODO 替换成OrgUtil里面的集合查询
     * @return 组织对象
     */
    public List<OrganizationDto> getOrganizationByIds(Collection<String> orgIds){
        return OrgUtils.getOrgListByOrgIds(new ArrayList<>(orgIds));
    }


}
